package com.pan.exe.driver.impl;

import com.pan.exe.Executive;
import com.pan.exe.driver.ExecutiveDriver;

import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 废弃
 * 预输入指令 缓存一个 1秒
 */
@Deprecated
public class CacheOneExecutiveDriver implements ExecutiveDriver {

    private ScheduledThreadPoolExecutor executor;

    private AtomicInteger flag;

    public CacheOneExecutiveDriver() {
        executor = new ScheduledThreadPoolExecutor(1);

    }

    @Override
    public void run(Executive executive) {

    }

    @Override
    public void close() {

    }
    //test
    public static void main(String[] args) {
        ScheduledThreadPoolExecutor executor1 = new ScheduledThreadPoolExecutor(1);
        Runnable task1 = ()->{
            System.out.println("任务一：阻塞3秒");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        };
        Runnable task2 = ()->{
            System.out.println("任务二：");
        };
        ScheduledFuture<?> schedule1 = executor1.schedule(task1, 1000, TimeUnit.SECONDS);
        System.out.println("1: "+schedule1);
        ScheduledFuture<?> schedule2 = executor1.schedule(task2, 4000, TimeUnit.SECONDS);
        System.out.println("2: "+schedule2);
    }
}
